<template>
  <div class="gosign">
    <!-- 签署表单 -->
    <form :action="post_url" id="form" method="post">
        <input type="hidden" name="sign_info" v-model="sign_info">
        <input type="hidden" name="nick_name" v-model="nick_name">
        <input type="hidden" name="return_url" v-model="return_url">
        <input type="hidden" name="number_id" v-model="number_id">
        <input type="hidden" name="mode" v-model="mode">
    </form>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        // 签署表单数据
        sign_info: '',
        nick_name: '',
        number_id: '',
        return_url: '',
        mode: '',
        post_url: ''
      }
    },
    created () {
      const acctKey = this.$route.query.acctkey

      this.$http.get('/api/user/authAcct', {
        params: {
          acctKey: acctKey
        }
      })
      .then((res) => {
        if (res.data.retCode === '0000') {
          const returnData = res.data.data

          this.sign_info = returnData.sign_info
          this.nick_name = returnData.nick_name
          this.return_url = returnData.return_url
          this.number_id = returnData.number_id
          this.post_url = returnData.post_url
          this.mode = returnData.mode
        }
      })
      .then(() => {
        const form = document.getElementById('form')
        form.action = this.post_url
        form.submit()
      })
    }
  }
</script>

<style lang='scss'>

</style>
